<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Home\Controller;
use OT\DataDictionary;
class FeedbackController extends HomeController {
    
    public  function Index(){

    }

   //联系我们
    public function feedback(){   
        $data= array();
        $data['title']=$_POST['contacts'];
        $data['f_name']=$data['title'];
        $data['email']=$_POST['email'];
        $data['tel'] = $_POST['phone'];
        $data['description']=$_POST['content'];
        if($data['title']==''||$data['tel']==''||$data['email']==''||$data['description']==''){
            $this->error('请输入完整信息');
        }
        $data['category_id']=$_GET['category_id'];
        $data['pid']=$_GET['pid'];
        $data['model_id']=$_GET['model_id'];
        $data['type']=2;
        $data['status'] =1; 
        $data['create_time']=  time();
        $data['update_time']=time();
        $res = D('Document')->updatefeedback($data);
        if(!$res){
            $this->error(D('Document')->getError());
        }else{            
            if (D('Email')->send_mail('', '','')) {
               $this->success($res['id'] ? '更新成功' : '發表成功，已通知商家', Cookie('__forward__'));
                } else {
                    $this->error('通知商家失敗');
                }
        }                    
  }

    
}